package com.sdy.healthcode.biz.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sdy.healthcode.biz.mapper.ManagerMapper;
import com.sdy.healthcode.biz.model.Manager;
import com.sdy.healthcode.biz.service.ManagerService;
import com.sdy.mvc.service.impl.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author cgj
 * @since 2020-02-28
 */
@Slf4j
@Service
public class ManagerServiceImpl extends BaseServiceImpl<Manager> implements ManagerService {
    @Autowired
    private ManagerMapper managerMapper;

    @Override
    public Manager getByPhone(String phone) {
        return lambdaQuery().eq(Manager::getPhone, phone).one();
    }

    @Override
    public Manager getById(Integer id) {
        return lambdaQuery().eq(Manager::getId, id).one();
    }

    @Override
    public boolean saveOne(Manager manager) {
        return save(manager);
    }

    @Override
    public void updById(Manager manager) {
        lambdaUpdate().eq(Manager::getId, manager.getId())
                .set(Manager::getName, manager.getName())
                .set(Manager::getPassword, manager.getPassword())
                .set(Manager::getPhone, manager.getPhone())
                .set(Manager::getState, manager.getState())
                .update();
    }

    @Override
    public Integer delbyId(Integer userId) {
        return managerMapper.deleteById(userId);
    }

    @Override
    public void updStaById(Integer id ,Integer sta) {
        lambdaUpdate()
                .eq(Manager::getId,id)
                .set(Manager::getState,sta)
                .update();
    }


}
